/*
 * @(#)BirthPlaceTransformer.java
 * Date 2013-08-16
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.pix.transformer;

import javax.enterprise.context.ApplicationScoped;

import javax.inject.Inject;

import javax.xml.bind.JAXBElement;

import org.hl7.v3.PRPAMT201301UV02BirthPlace;

import us.hornerscorners.lamppost.model.patient.BirthPlace;

import us.hornerscorners.lamppost.transformer.AbstractTransformer;


/**
 *
 * @author jim
 */
@ApplicationScoped
public class BirthPlaceTransformer
        extends AbstractTransformer<PRPAMT201301UV02BirthPlace, BirthPlace> {

    /** Field description */
    @Inject
    private PostalAddressTransformer postalAddressTransformer;

    /**
     * Constructs ...
     *
     */
    public BirthPlaceTransformer() {
        super();
    }

    /**
     * Method description
     *
     *
     * @param jaxbBirthPlace
     *
     * @return
     */
    public BirthPlace transform(JAXBElement<PRPAMT201301UV02BirthPlace> jaxbBirthPlace) {

        BirthPlace result = null;

        if (jaxbBirthPlace != null) {

            transform(jaxbBirthPlace.getValue());
        }

        return result;
    }

    /**
     * Method description
     *
     *
     * @param prpaBirthPlace
     *
     * @return
     */
    @Override
    public BirthPlace transform(PRPAMT201301UV02BirthPlace prpaBirthPlace) {

        BirthPlace result = null;

        if (prpaBirthPlace != null) {

            result = new BirthPlace();

            result.setPostalAddress(
                this.postalAddressTransformer.transform(prpaBirthPlace.getAddr()));
        }

        return result;
    }
}
